Skip to content

Add non-default find_duplicate tool gated by duplicate_detection flag - #3020

Open
michaeljacholke wants to merge 2 commits into
mainfrom
mj/find-duplicate-tool
Open

Add non-default find_duplicate tool gated by duplicate_detection flag#3020
michaeljacholke wants to merge 2 commits into
mainfrom
mj/find-duplicate-tool

Conversation

@michaeljacholke

@michaeljacholke michaeljacholke commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a read-only find_duplicate MCP tool that returns ranked duplicate candidates for an existing issue, gated behind a new opt-in duplicate_detection feature flag.

Why

Enables agents to answer "what likely duplicates this issue?" using GitHub's semantic-similarity endpoint, without adding schema cost to agents that haven't opted into duplicate detection. Semantic ranking stays server-side; the tool is a thin, read-only client.

Closes https://github.com/github/plan-track-agentic-toolkit/issues/690

What changed

  • Add find_duplicate tool (Issues toolset, read-only) calling GET /repos/{owner}/{repo}/issues/{issue_number}/semantically_similar
  • Add duplicate_detection feature flag to AllowedFeatureFlags (deliberately not in InsidersFeatureFlags so it's never implicitly enabled)
  • Map confidence_thresholdthreshold, perPageper_page, page; omit optional params when unset so the API's high-precision defaults apply. No client-side bounds on confidence_threshold — the API owns the scale (observed scores exceed 1)
  • Return a trimmed candidate — issue { number, title, state, url } (via the existing MinimalIssueRef) plus ranking metadata (score nullable, confidence, likely_duplicate) — rather than the full issue/repository payload
  • Surface a clear error for legacy bare-issue responses instead of a success-shaped empty list
  • Add unit tests, tool snapshot, and regenerate docs/feature-flags.md

MCP impact

  • New tool added
    • Adds find_duplicate to the Issues toolset. It is non-default and only registered when the duplicate_detection feature flag is enabled via --features or X-MCP-Features.

Prompts tested (tool changes only)

Tested against a local build (--features duplicate_detection, repo-scoped PAT), via both Agent-mode prompts and direct JSON-RPC calls:

  • Gating: find_duplicate is absent by default and present in tools/list only with the flag.
  • "Using find_duplicate, find likely duplicates of issue 769 in github/issues-agentic-sandbox" → returned 585 ("Improve the onboarding flow for new users"), score ~1.93, confidence "high", likely_duplicate true.
  • "Show the top 5 possible duplicates of issue 769 in that repo" (exercises perPage/confidence_threshold) → API returned the single genuine candidate; no error.
  • Empty case — issue with no similar issues → [] (successful, not an error).
  • Error case — a repo/issue where the endpoint isn't accessible → API 404 surfaced as an MCP tool error (isError: true), not a success-shaped empty result.

Security / limits

  • Auth / permissions considered
    • Uses the caller's existing GitHub authentication; repository visibility and issue authorization are enforced by the API. The tool is read-only and mutates nothing.
  • Data exposure, filtering, or token/size limits considered
    • Results are scoped to the source issue's repository (API-enforced), trimmed to a compact candidate shape to limit response size, and support pagination via perPage/page.

Tool renaming

  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Updated (README / docs / examples)
    • Regenerated docs/feature-flags.md (documents the duplicate_detection opt-in and the read-only, single-repository find_duplicate tool). README needs no change — gated tools are intentionally excluded from its tool listing.

@michaeljacholke
michaeljacholke marked this pull request as ready for review August 6, 2026 09:21
@michaeljacholke
michaeljacholke requested a review from a team as a code owner August 6, 2026 09:21
Copilot AI balanced review requested due to automatic review settings August 6, 2026 09:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in, read-only duplicate-detection tool using GitHub’s semantic-similarity endpoint.

Changes:

  • Adds ranked duplicate lookup with pagination and threshold support.
  • Gates registration behind duplicate_detection.
  • Adds tests, schema snapshot, and generated documentation.
Show a summary per file
File Description
pkg/github/tools.go Registers the new tool.
pkg/github/find_duplicate.go Implements duplicate lookup and response projection.
pkg/github/find_duplicate_test.go Tests schema, requests, responses, and errors.
pkg/github/feature_flags.go Defines the opt-in feature flag.
pkg/github/__toolsnaps__/find_duplicate_ff_duplicate_detection.snap Captures the tool schema.
docs/feature-flags.md Documents the flag and tool parameters.

Review details

  • Files reviewed: 6/6 changed files
  • Comments generated: 0
  • Review effort level: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants